function hrefBack() {
    history.go(-1);
}

function decodeQuery() {
    var search = decodeURI(document.location.search);
    return search.replace(/(^\?)/, '').split('&').reduce(function (result, item) {
        values = item.split('=');
        result[values[0]] = values[1];
        return result;
    }, {});
}

$(document).ready(function () {
    var mySwiper = new Swiper('.swiper-container', {
        loop: true,
        autoplay: 2000,
        autoplayDisableOnInteraction: false,
        pagination: '.swiper-pagination',
        paginationType: 'fraction'
    })
    $(".book-house").show();
    let hid = window.location.search;
    let house_id = hid.match('id=([^&]*)')[1];
    console.log(house_id)
    let url = '/api/v1.0/houses/' + house_id
    console.log(url)
    // $.get('/api/v1.0/houses/' + house_id, function (resp) {
    //     console.log(resp);
    // });
    $.ajax({
        url: '/api/v1.0/houses/' + house_id,
        type: 'get',
        dataType: 'json',
        success: function (resp) {
            console.log(resp);
            if (resp.errno = '0') {
                // $('.house-price span').html(resp.data.house.price / 100);
                let html = template('house-price', {price: resp.data.house.price});
                $('.house-price').html(html);
                let houses = template('detail-con', {house: resp.data.house});
                $('.detail-con').html(houses);
                if (resp.data.user_id == resp.data.house.user_id) {
                    $('.book-house').hide();
                }
            }

        }
    })
})